package com.aaa.dem1104.d01;

/**
 * @Author: whj
 * @Version 1.0
 * @Date: 2022/11/4  10:20
 */

import java.util.function.Function;
import java.util.function.Supplier;

/**
 * 构造方法引用
 */
public class Test4 {
    public static void main(String[] args) {
        //有参
        //Function<String,Doctor> function=(t)->new Doctor(t);
        Function<String,Doctor> function=Doctor::new;
        Supplier<Doctor>  supplier=()->new Doctor();
        Doctor doctor = function.apply("汪豪杰");
        System.out.println(doctor);



        //无参
//        Supplier<Doctor> supplier=Doctor::new;
//        System.out.println(supplier.get());
    }
}

class Doctor{
    private String name;

    public Doctor() {
    }

    public Doctor(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Doctor{" +
                "name='" + name + '\'' +
                '}';
    }
}
